import CommonHeader from '@/components/common-header/index'
import CommonInfo from '../components/CommonInfo/index'
import ApprovalButton from '../components/Button/index'
import { goTo } from '@/utils/goTo'
export default {
  name: '',
  components: {
    CommonHeader,
    CommonInfo,
    ApprovalButton,
  },
  data() {
    return {
      warn: '您有未填写的数据',
      approval: {
        leaveId: '',
      },
    }
  },
  onLoad(options) {
    this.approval.leaveId = options.id ? options.id : ''
    // console.log(options.id)
  },
  methods: {
    fieldClick() {
      goTo('/pages/classification/approval/destroy/id-selector/index')
    },
  },
  // 监听vuex中的数据变化，实时更新现在的外勤打卡地点
  computed: {
    nowDestroyId() {
      return this.$store.state.destroyId
    },
  },
  watch: {
    nowDestroyId: {
      handler(newVal, oldVal) {
        if (newVal) {
          this.approval.leaveId = newVal
        }
      },
      immediate: true,
      deep: true,
    },
    approval: {
      deep: true,
      handler: function(newV, oldV) {
        for (let key in newV) {
          if (!newV[key]) {
            return
          }
        }
        this.warn = ''
      },
    },
  },
}
